<template>
	<view class="container">
		<view class="team">
			<view class="team-item" v-for="(item, index) in list" :key="index" @click="toDetail(item)">
				<view class="team-img">
					<image
						:src="item.showImg || 'https://zrws-1327345771.cos.ap-shanghai.myqcloud.com/yanxue/team_style1.png'"
						mode="widthFix"
					></image>
				</view>
				<view class="team-info">
					<view class="info-left">
						<view class="team-title">{{ item.name }}</view>
						<view class="team-progress">
							<image src="https://zrws-1327345771.cos.ap-shanghai.myqcloud.com/yanxue/icon_success.png" mode="scaleToFill" />
							<view class="team-status">已上传</view>
							<view class="progress-text">{{ item.materialAmount }}</view>
						</view>
					</view>
					<view class="info-right"> 本地上传 > </view>
				</view>
			</view>
			<!-- <view v-if="list.length == 0" style="text-align: center; width: 100%">暂无数据</view> -->
			<view v-if="list.length == 0" style="width: 100%; text-align: center; margin-top: 200rpx">
				<image
					style="width: 500rpx"
					mode="widthFix"
					src="https://zrws-1327345771.cos.ap-shanghai.myqcloud.com/images/1734702481602ONCKpkWwYg0g4d9d4ebe77ff36c5ee1a1590746db1fb.png"
				/>
			</view>
		</view>
		<view class="btn_bottom" @click="addFeancai" v-if="options.edit == '1'">
			<view class="icon_plus"> + </view>
			<view class="btn_text"> 发起更多我的研学风采 </view>
		</view>
		<view class="mask" v-if="isShow" @click.stop="isShow = false">
			<view class="share" :style="{ bottom: numVh }" @click.stop="isShow = true">
				<view class="title">新增文件夹</view>
				<view class="onbtn" @click="setalbum">确定</view>
				<view class="input">
					<input type="text" v-model="wenjianming" placeholder="新增文件夹" />
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import indexApi from '@/api/yanxue/yanxue'
export default {
	data() {
		return {
			options: {},
			isShow: false,
			wenjianming: '',
			list: [],
			numVh: '-20vh'
		}
	},
	onLoad(options) {
		console.log(options)
		this.options = options
		this.getData()
	},
	methods: {
		toDetail(item) {
			let obj = {
				edit: this.options.edit,
				id: item.id
			}
			if (this.options.edit == '1' || this.options.ownType == '0') {
				this.$navTo('pagesA/teamStyle/team_style_detail', obj)
			} else {
				uni.showToast({ title: '只允许查看团队或自己的风采', icon: 'none' })
			}
		},
		addFeancai() {
			this.isShow = !this.isShow
			this.numVh = this.isShow ? '0vh' : '-20vh'
		},
		getData() {
			let obj = {
				bingInfoId: this.options.userId || 0,
				projectId: this.options.id
			}
			indexApi.getalbumList(obj).then(res => {
				console.log(res)
				this.list = res.result
			})
		},
		setalbum() {
			let obj = {
				bingInfoId: this.options.userId,
				name: this.wenjianming,
				projectId: this.options.id,
				type: this.options.userId == '0' ? 0 : 1 //  0.团队，1.个人
			}
			if (this.wenjianming.trim() == '') {
				return uni.showToast({ title: '请输入文件名', icon: 'none' })
			}
			indexApi.setalbumEdit(obj).then(res => {
				this.isShow = false
				uni.showToast({ title: '新增成功', icon: 'none' })
				this.getData()
			})
		}
	}
}
</script>

<style lang="scss" scoped>
.container {
	width: 100%;
	background: linear-gradient(0deg, #ffffff 0%, #c1f26c 100%);
	padding: 13px 12px 100px 12px;
	.team {
		display: flex;
		flex-wrap: wrap;
		.team-item {
			box-sizing: border-box;
			width: 351px;
			height: 228px;
			background: #ffffff;
			border-radius: 24px;
			overflow: hidden;
			margin-bottom: 10px;
			.team-img {
				width: 100%;
				height: 161px !important;
				position: relative;
				image {
					width: 100%;
					height: 161px !important;
					border-radius: 24px;
					overflow: hidden;
				}
			}
			.team-info {
				padding: 10px 22px 0 26px;
				display: flex;
				align-items: center;
				justify-content: space-between;
				.team-title {
					font-family: HarmonyOS Sans SC;
					font-weight: 400;
					font-size: 16px;
					color: #000000;
					line-height: 16px;
				}
				.team-progress {
					display: flex;
					align-items: center;
					margin-top: 14px;
					.team-status {
						font-size: 12px;
						color: #999999;
					}
					image {
						width: 15px;
						height: 15px;
						margin-right: 5px;
					}
					.progress-text {
						font-size: 12px;
						color: #999999;
						margin-left: 5px;
					}
				}
			}
		}
	}
	.btn_bottom {
		width: 231px;
		height: 33px;
		background: #f95513;
		border-radius: 17px;
		display: flex;
		align-items: center;
		justify-content: center;
		position: fixed;
		bottom: calc(env(safe-area-inset-bottom) + 36px);
		left: calc(50% - 115.5px);
		.icon_plus {
			width: 20px;
			height: 20px;
			border-radius: 20px;
			background-color: #fff;
			text-align: center;
			color: #f95513;
			font-size: 20px;
			font-weight: bold;
			line-height: 17.5px;
		}
		.btn_text {
			font-family: HarmonyOS Sans SC;
			font-weight: 500;
			font-size: 16px;
			color: #000000;
			margin-left: 10px;
		}
	}
	/*弹出框*/
	.mask {
		position: fixed;
		top: 0;
		left: 0;
		height: 100%;
		width: 100%;
		background: rgba(0, 0, 0, 0.7);
		z-index: 99;
		.share {
			width: 750rpx;
			height: 20vh;
			padding: 0 40rpx;
			position: fixed;
			left: 0;
			z-index: 100;
			transition: bottom 0.3s ease-in;
			background: #fff;
			border-top-right-radius: 30rpx;
			border-top-left-radius: 30rpx;
			.title {
				text-align: center;
				line-height: 80rpx;
				height: 80rpx;
				font-size: 16px;
				font-weight: bold;
			}
			.onbtn {
				position: absolute;
				top: 20rpx;
				font-weight: bold;
				right: 30rpx;
			}
			.input {
				flex: 1;
				margin-top: 15px;
				// width: 302px;
				height: 42px;
				background: #e8e8e8;
				border-radius: 21px;
				input {
					height: 42px;
					border-radius: 5px;
					padding: 0 25px;
				}
			}
		}
	}
}
</style>
